#include "wangge.h"
#include "ui_wangge.h"
#include<Qpainter>
#include <stdio.h>
#include<QTime>
#include<QPen>
int k=100+rand()%200,b=1,y[11],h=100+rand()%20,c=1;
wangge::wangge(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::wangge)
{
   // ui->setupUi(this);
    startTimer(200);
}

wangge::~wangge()
{
    //delete ui;
}
void wangge::paintEvent(QPaintEvent *)
{
    int i,a=100,l,j;
    QPainter painter(this);
    QPen pen(Qt::black);
    painter.setPen(pen);
    painter.drawLine(100,100,100,300);
    painter.drawLine(100,300,300,300);
    painter.drawLine(100,100,300,100);
    painter.drawLine(300,100,300,300);
    painter.drawLine(400,100,400,300);
    painter.drawLine(400,300,600,300);
    painter.drawLine(400,100,600,100);
    painter.drawLine(600,100,600,300);
    QPen pencil(Qt::blue);
    painter.setPen(pencil);
if(b==1)
{
    for(i=0;i<10;i++)
    {
        l=100+rand()%200;
        painter.drawLine(a,k,a+20,l);
        a=a+20;
        k=l;
        y[i]=l;
    }
    b=2;
}
else
{
    for(i=0;i<10;i++)
    {
       y[10]=100+rand()%200;
       painter.drawLine(a,y[i],a+20,y[i+1]);
       a=a+20;
       y[i]=y[i+1];
    }
}
if(c==1)
{
    for(i=0,a=400;i<10;i++)
    {
        j=100+rand()%200;
        painter.drawLine(a,h,a+20,j);
        a=a+20;
        h=j;
        g[i]=j;
    }
    c=2;
}
else
{
    for(i=0,a=400;i<10;i++)
    {
       g[10]=100+rand()%200;
       painter.drawLine(a,g[i],a+20,g[i+1]);
       a=a+20;
       g[i]=g[i+1];
    }
}
    QPen Stay(Qt::DotLine);
    painter.setPen(Stay);
    for(i=0,a=100;i<10;i++)
    {
      a=a+20;
      painter.drawLine(100,a,300,a);
      painter.drawLine(a,300,a,100);
      painter.drawLine(400,a,600,a);
      painter.drawLine(a+300,300,a+300,100);
    }
}
void wangge::timerEvent(QTimerEvent*)
{
    this->repaint();
}
